using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// Performer finite state machine.
/// </summary>
public class PfmFSM
{
    public MovState _curSt;
    private StIdle _stIdle;
    private StWalk _stWalk;
    private StRun _stRun;
    private StDash _stDash;
    private StDodge _stDodge;
    private StBlock _stBlk;
    private StSkill _stSkill;

    public PfmFSM(MainCtrl mc,int iptInterval)
    {
        _stIdle = new StIdle(SwcSt, mc);
        _stWalk = new StWalk(SwcSt, mc);
        _stRun = new StRun(SwcSt, mc, "Run", 120f);
        _stDash = new StDash(SwcSt, mc, "Dash", 200f, iptInterval);
        _stDodge = new StDodge(SwcSt, mc);
        _stBlk = new StBlock(SwcSt, mc);
        _stSkill = new StSkill(SwcSt, mc);
        SwcOn(StType.Idle);
    }

    private void SwcOn(StType st)
    {
        switch (st)
        {
            case StType.Idle:
                _curSt = _stIdle;
                break;
            case StType.Walk:
                _curSt = _stWalk;
                break;
            case StType.Run:
                _curSt = _stRun;
                break;
            case StType.Dash:
                _curSt = _stDash;
                break;
            case StType.Dodge:
                _curSt = _stDodge;
                break;
            case StType.Blk:
                _curSt = _stBlk;
                break;
            case StType.Skill:
                _curSt = _stSkill;
                break;
            case StType.OnHit://todo
                break;
            case StType.Cancel://todo
                break;
            default:
                break;
        }
        _curSt.Enter();
    }

    private void SwcSt(StType st)
    {
        _curSt.Exit();
        SwcOn(st);
    }
}
